<template>
    <div>
        <ModalComponent @open="handleOpen" modal-name="one-touch-create-modal" title="准考证" :close-on-click-modal="false"
            width="512px">

            <el-form :model="form" label-width="120px" label-position="top" size="large">
                <el-form-item label="">
                    <el-checkbox v-model="form.isSite">
                        重新分配考场
                    </el-checkbox>
                    <el-checkbox v-model="form.isExamNumber">
                        重新分配账号
                    </el-checkbox>
                </el-form-item>
                <el-form-item label="">
                    <el-button type="primary" @click="handleCreate">
                        生成
                    </el-button>
                </el-form-item>

            </el-form>
        </ModalComponent>
    </div>
</template>
<script setup >
import { onMounted, ref } from 'vue'
import ModalComponent from "@/components/modal/index.vue"
import { ElMessageBox } from 'element-plus';
const emit = defineEmits(['create'])
const form = ref({
    isSite: false,
    isExamNumber: false,
});
const handleOpen = () => {
    form.value = {
        isSite: false,
        isExamNumber: false,
    }
}
const handleCreate = () => {
    let str1 = form.value.isSite ? '【重置分配考场】' : ''
    let str2 = form.value.isSite ? '【重新分配账号】' : ''
    ElMessageBox.confirm(`确定一键为学生生成准考证并分配考场？${str1} ${str2}`, "提示", {
        "cancel-button-text": "取消",
        "confirm-button-text": "确定",
        type: "warning"
    }).then(async () => {
        let data = JSON.parse(JSON.stringify(form.value));
        data.isSite = data.isSite ? 1 : 0
        data.isExamNumber = data.isExamNumber ? 1 : 0
        emit('create', data)
    })
}
onMounted(() => {
    console.log('mounted!')
})
</script>
<style lang="scss" scoped>
.admission-ticket-info-container {
    width: 100%;
    text-align: center;
    padding: 0px;
    box-sizing: border-box;
}
</style>